package com.snoob.serviceLog.log.controller;

import com.alibaba.fastjson.JSONObject;
import com.snoob.serviceLog.log.entity.SysLogEntity;
import com.snoob.serviceLog.log.service.SysLogService;
import com.snoob.springcloudalibaba.base.BaseLogEntity;
import com.snoob.springcloudalibaba.base.BasePageResult;
import com.snoob.springcloudalibaba.pipleline.qo.SelectSysLogQo;
import com.snoob.springcloudalibaba.pipleline.vo.DeleteSysLogVoReq;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 系统日志 前端控制器
 * </p>
 *
 * @author lixing_java@163.com
 * @since 2022-05-17
 */
@RestController
@RequestMapping("sysLog")
@Component
public class SysLogController {
    @Resource
    private SysLogService sysLogService;

    /**
     * @描述 添加日志信息
     */
    @PostMapping("insertSysLog")
    public Long insertSysLog(@RequestBody BaseLogEntity baseLogEntity) {
        SysLogEntity sysLogEntity = JSONObject.parseObject(JSONObject.toJSONString(baseLogEntity), SysLogEntity.class);
        return sysLogService.insertSysLog(sysLogEntity);
    }

    /**
     * @描述 删除日志信息
     */
    @PostMapping("deleteSysLog")
    public Boolean deleteSysLog(@RequestBody DeleteSysLogVoReq vo) {
        return sysLogService.deleteSysLog(vo);
    }

    /**
     * @描述 查询日志信息
     */
    @PostMapping("selectSysLog")
    public SysLogEntity selectSysLog(@RequestBody SelectSysLogQo qo) {
        return sysLogService.selectSysLog(qo);
    }

    /**
     * @描述 分页查询企业信息
     */
    @PostMapping("selectEnterpriseByPage")
    public BasePageResult<SysLogEntity> selectEnterpriseByPage(@RequestBody SelectSysLogQo qo) {
        return sysLogService.selectSysLogByPage(qo);
    }
}

